//
//  AppDelegate.m
//  TravelWorld
//
//  Created by dllo on 15/5/21.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [_window release];
    
//    创建tabbar(主视图)
    [self creatTabbar];
    return YES;
}

- (void)creatTabbar{
    //    Tablebar第一个底部标签(世界)
    CountryViewController *countryCon = [[CountryViewController alloc] init];
    UINavigationController *countryNav = [[UINavigationController alloc] initWithRootViewController:countryCon];
    //    图片
    UIImage *countryImg = [UIImage imageNamed:@"1.jpg"];
    countryImg = [countryImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //    选择后图片
    UIImage *countrySelImg = [UIImage imageNamed:@"1.jpg"];
    countrySelImg = [countrySelImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    countryNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"世界" image:countryImg selectedImage:countrySelImg];
    
    ChinaViewController *chinaCon = [[ChinaViewController alloc] init];
    UINavigationController *chinaNav = [[UINavigationController alloc] initWithRootViewController:chinaCon];
    UIImage *chinaImg = [UIImage imageNamed:@"1.jpg"];
    chinaImg = [chinaImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *chinaSelImg = [UIImage imageNamed:@"1.jpg"];
    chinaSelImg = [chinaSelImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    chinaNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"中国" image:chinaImg selectedImage:chinaSelImg];
    
    ThemeViewController *themeCon = [[ThemeViewController alloc] init];
    UINavigationController *themeNav = [[UINavigationController alloc] initWithRootViewController:themeCon];
    UIImage *themeImg = [UIImage imageNamed:@"1.jpg"];
    themeImg = [themeImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *themeSelImg = [UIImage imageNamed:@"1.jpg"];
    themeSelImg = [themeSelImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    themeNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"主题" image:themeImg selectedImage:themeSelImg];
    
    FindViewController *findCon = [[FindViewController alloc] init];
    UINavigationController *findNav = [[UINavigationController alloc] initWithRootViewController:findCon];
    UIImage *findImg = [UIImage imageNamed:@"1.jpg"];
    findImg = [findImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *findSelImg = [UIImage imageNamed:@"1.jpg"];
    findSelImg = [findSelImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    findNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发现" image:findImg selectedImage:findSelImg];
    
    MineViewController *mineCon = [[MineViewController alloc] init];
    UINavigationController *mineNav = [[UINavigationController alloc] initWithRootViewController:mineCon];
    UIImage *mineImg = [UIImage imageNamed:@"1.jpg"];
    mineImg = [mineImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *mineSelImg = [UIImage imageNamed:@"1.jpg"];
    mineSelImg = [mineSelImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mineNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:mineImg selectedImage:mineSelImg];
    
    
    //    创建tabbar
    UITabBarController *tabbarController = [[UITabBarController alloc] init];
    tabbarController.tabBar.barTintColor = [UIColor lightGrayColor];
    tabbarController.tabBar.tintColor = [UIColor grayColor];
    tabbarController.viewControllers = [NSArray arrayWithObjects:countryNav, chinaNav, themeNav, findNav, mineNav, nil];
    self.window.rootViewController = tabbarController;
    
    //    修改所有的导航栏样式
    [UINavigationBar appearance].translucent = NO;
    [[UINavigationBar appearance] setBarTintColor:[UIColor lightGrayColor]];
}
- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
